package com.heima.user.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.dtos.UserRelationDto;
import com.heima.user.service.UserFollowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/v1/user")
public class UserFollowController {

    @Autowired
    private UserFollowService userFollowService;

    /**
     * 用户关注
     *
     * @param relationDto
     * @return
     */
    @PostMapping("/user_follow")
    public ResponseResult userFollow(@RequestBody UserRelationDto relationDto, @RequestHeader("userId") String userId){
        log.info("用户是否关注：{},用户id：{}",relationDto.getOperation() == 0 ? "关注":"取消关注",userId);
        return userFollowService.userFollow(relationDto,userId);
    }
}
